/**
 * 
 */
package com.cgbsoft.financial.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * @author CX
 *
 */
public class DataBaseHelper extends SQLiteOpenHelper {
	
	//数据库名字
	/** 数据库名 */
	private static final String DATABASE_NAME = "com.cgbsoft.financial";
	/** 数据库版本 */
	private static final int DATABASE_VERSION = 1;
	
	//表名
	/** 输入缓存 */
	public static final String T_TRANSTION_CACHE = "T_TRANSTION_CACHE";
	/** 保存的帐单记录 */
	public static final String T_TRANSTION = "T_TRANSTION";
	
	
	/**
	 * 构造函数
	 * @param context
	 */
	public DataBaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		//创建表
		db.execSQL("CREATE TABLE "
				+ T_TRANSTION_CACHE
				+ " (_id integer primary key autoincrement, " +
						"DATE text," +
						"SUM text," +
						"SUBJECT text," +
						"CATEGORY text," +
						"M_COUNT integer);");
		
		db.execSQL("CREATE TABLE "
				+ T_TRANSTION
				+ " (_id integer primary key autoincrement, " +
						"DATE text," +
						"SUM text," +
						"SUBJECT text," +
						"CATEGORY text);");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
		db.execSQL("DROP TABLE IF EXISTS " + T_TRANSTION_CACHE);
		db.execSQL("DROP TABLE IF EXISTS " + T_TRANSTION);
		onCreate(db);
	}
	
}
